package cn.itsource.basic.domain;

import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.digest.MD5;

/**
 * 钩子写法
 */
public interface CreatePassword {
    String getPassword();

    void setPassword(String password);

    String getSalt();

    void setSalt(String salt);

    default void init() {
        //1.1搞个盐
        String salt = IdUtil.fastSimpleUUID();
        //1.2加盐加密
        String pwd = MD5.create().setSalt(salt.getBytes()).digestHex(this.getPassword());
        this.setSalt(salt);
        this.setPassword(pwd);
    }
}
